<?php
class model_catalog_sub extends model_version {
	public $pk = "uuid";
	public $table = "catalog_sub";
	public function model_version_delete_byPk($pk, $insertLog = false, $deleteRelativeRecords = false) {
		if ($deleteRelativeRecords) {
			//delete sub catalog image
			$exist_data = $this->get ( $pk );
			if (strlen ( $exist_data ['resource_uuid'] ) > 0) {
				$resource_obj = spClass ( "model_resource" );
				$resource_obj->deleteByPk ( $exist_data ['resource_uuid'] );
			}
			
			//delete catalog list data
			$catalog_sub_list_db_obj = spClass ( "model_catalog_sub_video" );
			$sub_catalog_list_list_data = $catalog_sub_list_db_obj->findAll ( array ('sub_catalog_uuid' => $exist_data ['uuid'] ) );
			foreach ( $sub_catalog_list_list_data as $sub_catalog_list_data ) {
				$catalog_sub_list_db_obj->model_version_delete_byPk ( $sub_catalog_list_data [$catalog_sub_list_db_obj->pk], $insertLog, $deleteRelativeRecords );
			}
		}
		parent::model_version_delete_byPk ( $pk, $insertLog );
	}
}